import 'package:eplorex/pages/map/map_select_location_page.dart';
import 'package:flutter/material.dart';

import '../../providers/local_db.dart';
import '../../widgets/my_page_cell.dart';
import '../map/map_location_page.dart';
import '../map/map_show_page.dart';
import '../payment/payment_demo_page.dart';
import 'my_page_child.dart';
import 'notification_page.dart';

class CreatorPage extends StatefulWidget {
  const CreatorPage({super.key});

  @override
  State<CreatorPage> createState() => _CreatorPageState();
}

class _CreatorPageState extends State<CreatorPage> {
  final List<Widget> _cellChildPage = [
    MyPageChild(title: "默认页"),
    LocationMapPage(),
    MapSelectLocation(),
    NotificationPage("通知"),
    PaymentDemoPage(),
  ];

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('功能实验室'),
      ),
      body: Container(
        child: ListView(
          children: [...getTile()],
        ),
      ),
    );
  }

  List<Widget> getTile() {
    return [
      MyInfoCell(
        imageName: "images/coupon_icon.png",
        title: "优惠券",
        child: _cellChildPage[0],
      ),
      Container(
        height: 1,
      ),
      MyInfoCell(
          imageName: "images/map_location_icon.png",
          title: "定位",
          child: _cellChildPage[1]),
      Container(
        height: 1,
      ),
      MyInfoCell(
          imageName: "images/help_icon.png",
          title: "地图",
          child: _cellChildPage[2]),
      Container(
        height: 1,
      ),
      Container(
        height: 1,
      ),
      MyInfoCell(
          imageName: "images/settings_icon.png",
          title: "通知消息",
          child: _cellChildPage[3]),
      Container(
        height: 1,
      ),
      GestureDetector(
        child: MyInfoCell(
            imageName: "images/settings_icon.png",
            title: "清除缓存",
            child: _cellChildPage[3]),
        onLongPress: () => {
          _onTapCleanCache()
        },
      ),
      GestureDetector(
        child: MyInfoCell(
            imageName: "images/settings_icon.png",
            title: "支付",
            child: _cellChildPage[4]),
        onTap: () => _onTapCleanCache(),
      ),
    ];
  }

  _onTapCleanCache() {
    DatabaseHelper.instance.cleanCache();
  }
}
